#include <iostream>
using namespace std;

// s-vstupni retezec, SA-vystupni suffix array, n-delka retezce, K-pocet znaku abecedy
// pole `s` a `SA` potrebujou mit naalokovano n+3 prvku pro n >= 2
void suffixArray(int* s, int* SA, int n, int K);

// find the suffix array SA of s[0..n-1] in {1..K}^n
// require s[n-1]=0 (the sentinel!), n>=2
// use a working space (excluding s and SA) of at most 2.25n+O(1) for a constant alphabet
// --
// s-vstupni retezec, SA-vystupni suffix array, n-delka retezce,
// K-pocet znaku abecedy, cs-velikost datoveho typu s (napr. sizeof(unsigned char))
void SA_IS(unsigned char *s, int *SA, int n, int K, int cs);

int main(int argc, char **argv)
{
	char *str = "swiss miss";
	int n = 10;
	//int* s = new int[n+3];
	int* SA = new int[n+3];
	//for (int i = 0;  i < n;  i++) s[i] = SA[i] = 1;
	//s[n] = s[n+1] = s[n+2] = SA[n] = SA[n+1] = SA[n+2] = 0;
	//for(int i = 0; i < n; i++) s[i] = str[i];
	//suffixArray(s, SA, n, 256);
	SA_IS((unsigned char *)str, SA, n+1, 256, sizeof(char));
	cout << "Suffix Array =";
	for(int i = 0; i < n; i++) cout << ' ' << SA[i];
	cout << endl;
	//delete [] s;
	delete [] SA;
}
